package org.su.webadapter.bind;

import javax.servlet.ServletRequest;
import java.util.Enumeration;

/**
 * Created by yangchuan on 16/9/18.
 */
public abstract class AbstractBeanEditor {
    /**
     * 判断请求中是否包含该参数名称。A--Set<B>--Set<C>--A等这样的循环后,在查找参数的时候出现死循环
     * @param paramName
     * @param request
     * @return
     */
    protected boolean isContinueParam(String paramName, ServletRequest request) {
        Enumeration<String> pNames = request.getParameterNames();
        String pName = null;
        boolean isContinue = false;
        int len = paramName.length();
        while (pNames.hasMoreElements()) {
            pName = pNames.nextElement();
            if(pName.length() < len){
                continue;
            }
            if (pName.startsWith(paramName)) {
                isContinue = true;
                break;
            }
        }
        pNames = null;
        pName = null;
        return isContinue;
    }
}
